<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePetsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('pets', function (Blueprint $table) {
            $table->id();
            $table->foreignId('article_id')->constrained('articles')->onDelete('cascade');
            $table->string('title', 100)->nullable()->comment('标题');
            $table->string('url')->nullable()->comment('跳转链接');
            $table->text('content')->nullable()->comment('内容');
            $table->string('source', 30)->nullable()->comment('来源');
            $table->unsignedInteger('click')->nullable()->comment('点击数');
            $table->string('preview')->nullable()->comment('缩略图');
            $table->json('images')->nullable()->comment('图片信息');
            $table->string('description')->nullable()->comment('文章介绍');
            $table->json('extra')->nullable()->comment('扩展字段');
            $table->string('keywords')->index()->nullable()->comment('关键字，用于搜索');
            $table->string('author')->nullable()->comment('文章作者');
            $table->string('template')->nullable()->comment('模板');
            $table->boolean('recommend')->default(false)->nullable()->comment('是否推荐');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('pets');
    }
}
